FROM debian:13

RUN echo "正在设置镜像站"
RUN sed -i 's/deb.debian.org/mirrors.huaweicloud.com/g' /etc/apt/sources.list.d/debian.sources


RUN echo "正在设置编译环境"
RUN apt update && apt upgrade -y && apt install wget cmake init openssh-server -y && apt install -y build-essential make gcc flex autoconf bison tclsh gettext zlib1g-dev liblzma-dev pkg-config jq zip unzip && apt install -y openjdk-21-jdk python3 python3-pip python3-setuptools python3-wheel gawk tar git && pip3 config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple && pip3 install meson ninja --break-system-packages
RUN echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config && cd ~ && git clone https://gitee.com/nanqu_ait/commandline-tools-linux-x64_01.git && cd commandline-tools-linux-x64_01 && bash ./download.sh && cd ~ && rm -rf ~/commandline-tools-linux-x64_01
RUN cd /opt/tmp/commandline && unzip commandline-tools-linux-x64-5.0.13.230.zip -d ../ && cd ../ && rm -rf ./commandline/* && unzip ./commandline-tools-linux-x64-5.0.13.230.zip -d /opt && rm -rf /opt/tmp/*
RUN cd /root && echo 'export TOOL_HOME=/opt/command-line-tools/' > termony.env && echo 'export PATH=${TOOL_HOME}/bin:${PATH}' >> termony.env
RUN cat /root/termony.env >> /etc/profile

RUN echo "正在克隆项目"
RUN cd /root && git clone https://github.com/TermonyHQ/Termony.git && cd /root/Termony &&  echo 'registry=https://repo.huaweicloud.com/repository/npm/' > .npmrc && echo '@ohos:registry=https://repo.harmonyos.com/npm/' >> .npmrc && cd /root/Termony && git submodule update --init --recursive

# 如果网络环境允许直接编译可以取消下面的注释
# RUN cd /root/Termony && bash ./build-linux.sh -b